#define _CRT_SECURE_NO_WARNINGS   1
#include"Slist.h"

void Print(SLNode* phead)
{
	SLNode* tail = phead;
	while (tail->Next != NULL)
	{
		printf("%d",tail->val);
	}


}


SLNode* CreatNewNode(SLNodetype x)
{
	SLNode* NewNode = (SLNode*)malloc(sizeof(SLNode));
	NewNode->val = x;
	NewNode->Next = NULL;
	return NewNode;
}


void SLNodePushback(SLNode* phead, SLNodetype x)
{
	SLNode* NewNode = CreatNewNode(x);
	SLNode* tail = phead;
	if (NULL==phead)
	{
		phead = NewNode;
	}
	else {
		while (tail->Next == NULL)
		{
			tail = tail->Next;

		}
		tail->Next = NewNode;
	}
	

}

void SLNodePushfront(SLNode* phead, SLNodetype x)
{
	SLNode* NewNode = CreatNewNode(x);
	if (NULL == phead)
	{
		phead = NewNode;
	}
	else {
		NewNode->Next = phead;
		phead = NewNode;


	}

}
